package models

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	ShopId int64   `json:"type:int(2);comment:'商家ID'"`
	Title  string  `json:"type:varchar(30);comment:'商品名称'"`
	Price  float64 `json:"type:decimal(10,2);comment:'商品价格'"`
	Stock  int64   `json:"type:int(3);comment:'商品库存'"`
}

func (g *Goods) GetGoodsById(goodsId int64) error {
	return DB.Where("id=?", goodsId).Limit(1).Find(&g).Error
}

func (g *Goods) CreateGoods() error {
	return DB.Create(&g).Error
}
